// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asAssetGroup.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the AssetGroup class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asAssetGroup.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "asHasEvents.h"
#include "../ScriptHelper.h"

#include "../../core/AssetGroup.h"


//! Reference factory for the AssetGroup class.
AssetGroup* createAssetGroup(const std::string &name, const std::string &dirName)
{
    return new AssetGroup(name, dirName);
}

//! Binds the AssetGroup class to AngelScript.
void bindAssetGroup(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind AssetGroup class (and dependencies).
    r = engine->RegisterObjectType("AssetGroup", sizeof(AssetGroup), asOBJ_REF);
    r = engine->RegisterObjectType("AssetProcessor", sizeof(AssetProcessor), asOBJ_REF);

    // Bind inherited functions.
    bindHasEventsBase<AssetGroup>(engine, "AssetGroup");

    // Set AssetGroup behaviour.
    r = engine->RegisterObjectBehaviour("AssetGroup", asBEHAVE_FACTORY, "AssetGroup@ f(const string &in, " \
                                        " const string &in)", asFUNCTION(createAssetGroup), asCALL_CDECL);
                                        assert(r >= 0);
    r = engine->RegisterObjectBehaviour("AssetGroup", asBEHAVE_ADDREF, "void f()",
                                        asMETHOD(AssetGroup, grab), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("AssetGroup", asBEHAVE_RELEASE, "void f()",
                                        asMETHOD(AssetGroup, drop), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("AssetGroup", "AssetGroup& opAssign(const AssetGroup &in)",
                                        asFUNCTION(assignT<AssetGroup>), asCALL_CDECL_OBJLAST); assert(r >= 0);

    // Bind AssetGroup class functions.
    r = engine->RegisterObjectMethod("AssetGroup", "u32 getID()",
                                     asMETHOD(AssetGroup, getID), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AssetGroup", "const string& getName()",
                                     asMETHOD(AssetGroup, getName), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AssetGroup", "const string& getBaseDir()",
                                     asMETHOD(AssetGroup, getBaseDir), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("AssetGroup", "AssetProcessor@ getAssetProcessor(const string &in)",
                                     asMETHOD(AssetGroup, getAssetProcessor), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("AssetGroup", "bool reloadAsset(const string &in)",
                                     asMETHOD(AssetGroup, reloadAsset), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AssetGroup", "void reloadAssets()",
                                     asMETHOD(AssetGroup, reloadAssets), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("AssetGroup", "bool removeAsset(const string &in)",
                                     asMETHOD(AssetGroup, removeAsset), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AssetGroup", "void removeAssets()",
                                     asMETHOD(AssetGroup, removeAssets), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
